package com.spring.demo7.eg2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author vhans
 */
@Configuration
public class MainConfig1 {

    @Bean
    // 2.和@Bean一起用在方法上，指定在创建serviceA之前先创建ServiceB和ServiceC
    @DependsOn({"serviceB", "serviceC"})
    public ServiceA serviceA() {
        return new ServiceA();
    }

    @Bean
    public ServiceB serviceB() {
        return new ServiceB();
    }

    @Bean
    public ServiceC serviceC() {
        return new ServiceC();
    }
}
